package figurs;

import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.Shape;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.PointList;
import org.eclipse.draw2d.geometry.Rectangle;

public class TrepezeBot extends Shape {
	static PointList points = new PointList();
	protected static int whitht;

	public TrepezeBot(int w) {
		whitht = w;
	}

	protected void fillShape(Graphics graphics) {
		graphics.fillPolygon(getPoints(getBounds()));
	}

	protected void outlineShape(Graphics graphics) {
		graphics.drawPolygon(getPoints(getBounds()));
	}

	private static PointList getPoints(Rectangle r) {
		points.removeAllPoints();
		points.addPoint(r.getTopRight());
		points.addPoint(r.getTopLeft());
		Point p = r.getBottom();
		p.setX(p.x - ((int)  whitht/6));
		p.setY(p.y - 1);
		points.addPoint(p);
		p = r.getBottom();
		p.setX(p.x + ((int) whitht/6));
		p.setY(p.y - 1);
		points.addPoint(p);
		return points;
	}
}